The usable data stored within a database may be logically stored in one or more tablespaces and may be physically stored in one or more data files associated with a particular tablespace. A tablespace is a set of one or more data files that are used to store data for a database object, such as a table or table partition. Database metadata defines tablespaces and the database objects for which a tablespace stores data. A database administrator may use a tablespace to do one or more of the following: control disk space allocation for data stored in the database, assign specific space quotas for database users, control the availability of data by taking individual tablespaces online or offline, perform partial database backup or recovery operations, and allocate data storage access devices to improve performance.
A data file (or simply “file”) is associated with a particular tablespace and physically stores data in the tablespace. A data file is composed of one or more logical storage units. For example, a data file may be composed of one or more extents. Each extent is a logical grouping of one or more data blocks. A data block is an allocation of contiguous storage space within data files that is used to store database data. The size of each data block in a tablespace is the same. A typically size of a data block is 2K, 4K, 8K, or 16K.
Storage space within a data file that is not allocated to a database object is free space. The number of extents that are not allocated to any object is stored in the first block of a file. By aggregating the amount of free space across all data files in a tablespace, one can determine how much free space is available in the tablespace.
Tablespaces can have a fixed size. When a database administrator creates a new tablespace, the database administrator may not know how much data will be stored within the new tablespace or the growth rate for data stored within the new tablespace; nevertheless, the database administrator chooses a fixed size for the tablespace upon its creation.
When the amount of data stored within a tablespace exceeds a certain size or threshold, it is advantageous to increase the size of the tablespace to ensure that the tablespace does not run out of space. Additionally, providing that a certain minimum level of free space exists in the tablespace ensures that storing data in the tablespace will be performed with optimal performance.
Currently, the amount of free space available in a database is determined by a database server by periodically examining the database to determine: (a) how many tablespaces are in the database, (b) how many data files are in each tablespace in the database, and (c) how many data blocks are in each data file in each tablespace in the database. A data file contains information about the number of allocated data blocks within the data file. The free space for each data file in each tablespace in the database is aggregated to determine if the amount of free space in a tablespace in the database is below a specified threshold. This technique of determining the amount of free space in a database shall be referred to hereafter as “polling” the database.
If the amount of free space in a tablespace in the database is below a specified threshold, then the database server may raise an alert to the database administrator. Upon receiving the alert, the database administrator may increase the size of the tablespace to increase the amount of free space in that tablespace.
This approach undesirably requires a significant amount of time and computing resources to determine the amount of free space within a tablespace. For example, if a tablespace contained 100 data files, but only 10 data files are associated with data blocks that have either been allocated or deallocated since the last time the amount of free space in the tablespace was determined, then the above approach would still require that each of the 100 data files be consulted to determine the free space in the tablespace, even though 90 of the data files were unchanged since the last time the amount of free space was determined in the tablespace.
Accordingly, there is an unaddressed need in the art to determine the usage of space in a database without incurring the problems associated with prior approaches.
The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.